﻿<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>

    <title>FERI Novice</title>

	  <link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8"/>


      <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

      <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>

      <script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>

      <script type="text/javascript">

          function loadXMLDoc() {

              //var symbol = "MSFT";
              var xmlhttp = new XMLHttpRequest();
              xmlhttp.open("POST", "http://164.8.251.99:9793/services/cir2012/SiNf_FeriNews?wsdl", false); //spremeni wsdl
              xmlhttp.onreadystatechange = function () {
                  if (xmlhttp.readyState == 4) {
                      var xmlString = xmlhttp.responseText;

                      var parser = new DOMParser();
                      var xmlDoc = parser.parseFromString(xmlString, "application/xml");

                      var stevilo = xmlDoc.getElementsByTagName("obvestilo"); //spremeni tag name

                      //alert(stevilo.length);

                      
                      for (var i = 0; i < stevilo.length; i++) {
                      var povezava = xmlDoc.getElementsByTagName("obvestilo")[i].getAttribute("povezava"); //spremeni var, atribut in tag name
                      var obvestilo = xmlDoc.getElementsByTagName("obvestilo")[i].childNodes[0].nodeValue; //spremeni atribut in var

                      document.getElementById("main").innerHTML += "<a href='" + povezava + "'>" + obvestilo + "</a></br></br>"; //spremeni spremenljivke
                      }                      

                  }
              }

              xmlhttp.setRequestHeader("SOAPAction", "feriNovice"); //spremeni drugi parameter
              xmlhttp.setRequestHeader("Content-Type", "text/xml");
              var xml = '<?xml version="1.0" encoding="utf-8"?>' +
                 '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
                                'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
                                'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' +
                   '<soap:Body> ' +
                     '<feriNovice xmlns="http://services.mashup.wso2.org/SiNf_FeriNews/"> ' + //spremeni url in kaj vrne, mora biti isto, kot zgoraj pri SOAPAction
                     '</feriNovice> ' +
                   '</soap:Body> ' +
                 '</soap:Envelope>';
              xmlhttp.send(xml);

              

          }

            document.addEventListener("deviceready", loadXMLDoc, false);

        </script>

</head>

<body>
    <h2>FERI News</h2> <!-- spremeni naslov strani -->
    <div id="main"></div>
</body>

</html>
